<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新增</title>
</head>
<body>
<div>
    <!--    <input type="hidden" id="id">-->
    <div>
        <label>
            课程名字：<input type="text" id="courseName">
        </label>
    </div>
    <div>
        <label>
            课程编码：<input type="text" id="courseNo">
        </label>
    </div>
    <div>
        <button onclick="addClick()">提交</button>
    </div>
</div>
<script src="ajax.js"></script>
<script>
    function addClick() {
        add();
    }

    function showRes(jsonObj) {
        location.href = "courseList.html"
    }
    function add() {
        let nameStr = document.getElementById("courseName").value;//名字
        let numStr = document.getElementById("courseNo").value;
        let formData = new FormData();//表单数据对象，即键值对
        formData.append("courseName", nameStr);
        formData.append("courseNo", numStr);
        ajax("course/add.php", "POST", formData, showRes);

    }
</script>
</body>
</html>